package com.it.sun.esaychat.chat.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.it.sun.easychat.common.jdbctypehandler.ListTypeHandler;
import com.it.sun.easychat.common.jdbctypehandler.UserTypeHandler;
import com.it.sun.easychat.model.vo.UserVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author sunmannian
 * @since 2020-05-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("e_chat_base_message")
@ApiModel(value="MessageEntity对象", description="")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class MessageEntity implements Serializable {

    private static final long serialVersionUID=1L;

    @TableId(value = "id_", type = IdType.ASSIGN_ID)
    private String id;

    @ApiModelProperty(value = "消息内容")
    @TableField("content_")
    private String content;

    @ApiModelProperty(value = "消息类型：文件、照片、文本、视频、音频",example = "1")
    @TableField("type_")
    private Integer type;

    @ApiModelProperty(value = "消息发送人")
    @TableField(value = "from_" ,typeHandler = UserTypeHandler.class)
    private UserVO from;

    @ApiModelProperty(value = "消息接收者")
    @TableField(value = "to_",typeHandler = ListTypeHandler.class)
    private List<UserVO> to;

    @TableField(value = "delete_", fill = FieldFill.INSERT)
    @TableLogic
    private Integer delete;

    @TableField(value = "create_time_", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @TableField(value = "update_time_", fill = FieldFill.INSERT_UPDATE)
    @JsonIgnore
    private LocalDateTime updateTime;

    @ApiModelProperty(value = "是否群聊消息",example = "1")
    @TableField(value = "broadcast_")
    private Integer broadcast;


}
